package cn.wu.reggie.mapper;

import cn.wu.reggie.dto.SetmealDto;
import cn.wu.reggie.entity.Dish;
import cn.wu.reggie.entity.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

public interface SetmealMapper {

    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> findByCategoryId(Long categoryId);

    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @SelectKey(statement = "select last_insert_id()",before = false,keyProperty = "id",keyColumn = "id",resultType = Long.class)
    void save(SetmealDto setmealDto);


    List<Setmeal> findAll(String name);

    void batchDelete(Long[] ids);

    List<Setmeal> findOnSaleByIds(Long[] ids);

    @Select("select * from setmeal where category_id = #{categoryId} and status = #{status}")
    List<Setmeal> findByCategoryIdAndStatus(@Param("categoryId") Long categoryId,@Param("status") Integer status);
}
